package exercise;

import framework.Factory;
import framework.Product;

import java.util.HashMap;

public class IDCardFactory extends Factory {

    private HashMap<String, String> database = new HashMap<String, String>();

    private int serial = 100;

    protected synchronized Product createProduct(String owner) {
        return new IDCard(owner, serial++);
    }

    protected void registerProduct(Product product) {
        IDCard idCard = (IDCard) product;
        String owner = idCard.getOwner();
        database.put(serial + "", owner);
    }

    public HashMap<String, String> getDatabase() {
        return database;
    }
}
